<table width="530" style="margin-left:20px;" class="location-list">
  <tbody><tr>
      <?php if ($locations): ?>
        <?php $i = 0; foreach ($locations as $location): ?>
          <?php if (($i > 0) && ($i % 4 == 0)) : ?></tr><tr><?php endif; ?>
          <td><span locid="<?php echo $location->id ?>" class="location"><?php echo check_plain($location->title) ?></span></td>
        <?php $i++; endforeach; ?>
      <?php endif; ?>
    </tr></tbody>
</table>